var Likes = new Class.create();
Likes.prototype = {
    uid:0,
    interval:0,
    initialize:function(){
        var uid = getLocData("uid")
        if (!isTrue(uid)) {
            this.uid = 0;
        }else {
            this.uid = uid;
        }
    }
    ,_add:function (id) {
        if (!this._isLike(id)) {
            var data = getLocData("MyLikesData");
            if (!isTrue(data)) {
                data = {}
            }
            data["index_" + this.uid+"_"+id ] = id;
            setLocData("MyLikesData",data)
        }
    }
    ,_del:function (id) {
        if (this._isLike(id)) {
            var data = getLocData("MyLikesData");
            var index = "index_" + this.uid+"_"+id;
            data = objDelIndex(data,index)
            setLocData("MyLikesData",data)
        }
    }
    ,_isLike:function (id) {
        var data = getLocData("MyLikesData");
        if (!isTrue(data)) {
            return false
        }else {
            for (var i in data) {
                var a = i.split("_");
                if (a[1] == this.uid && a[2] == id) {
                    return true
                }
            }
            return false
        }
    }
    ,click:function (id,addFunc,delFunc) {
        var re = true;
        //延迟请求网络
        clearTimeout(this.interval)
        if (this._isLike(id)) {
            this._del(id)
            re = false
            this.interval = setTimeout(delFunc,2000)
        }else {
            this._add(id)
            re = true
            this.interval = setTimeout(addFunc,2000)
        }
        return re;
    }
}